package cn.wolfcode.p2p.controller;

import cn.wolfcode.p2p.base.query.QueryObject;
import cn.wolfcode.p2p.business.domain.PlatformBankInfo;
import cn.wolfcode.p2p.business.service.IPlatformBankInfoService;
import cn.wolfcode.p2p.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class PlatformBankInfoController {

    @Autowired
    private IPlatformBankInfoService bankInfoService;

    @RequestMapping("companyBank_list")
    public String companyBank(@ModelAttribute("qo") QueryObject qo, Model model) {

        model.addAttribute("pageInfo", bankInfoService.listForPage(qo));
        return "platformbankinfo/list";
    }

    @RequestMapping("companyBank_update")
    @ResponseBody
    public JsonResult saveOrUpdate(PlatformBankInfo bankInfo) {
        if (bankInfo.getId() != null) {
            bankInfoService.update(bankInfo);
        }else{
            bankInfoService.save(bankInfo);
        }
        return JsonResult.instance();
    }
}
